import apiClient from '../apiClient';

const getListApi = (uri: string, params: any) =>
  apiClient.get<any>({ url: `/admin/${uri}/page`, params });
const getApi = (uri: string, params: any) =>
  apiClient.get<any>({ url: `/admin/${uri}/get`, params });
const addApi = (uri: string, data: any) => apiClient.post<any>({ url: `/admin/${uri}/add`, data });
const editApi = (uri: string, data: any) => apiClient.put<any>({ url: `/admin/${uri}/edit`, data });
const setPermApi = (uri: string, data: any) =>
  apiClient.post<any>({ url: `/admin/${uri}/setPrivilege`, data });
const auditApi = (uri: string, data: any) =>
  apiClient.put<any>({ url: `/admin/${uri}/audit`, data });
const delApi = (uri: string, params: any) =>
  apiClient.delete<any>({ url: `/admin/${uri}/delete`, params });
const getInfoApi = (uri: string, params: any) =>
  apiClient.get<any>({ url: `/admin/${uri}/resource`, params });
const getCateListApi = (uri: string, params: any) =>
  apiClient.get<any>({ url: `/admin/${uri}/getTree`, params });
const getMenuApi = (uri: string, params: any) =>
  apiClient.get<any>({ url: `/admin/${uri}/resource`, params });
const getMenuIdsApi = (uri: string, params: any) =>
  apiClient.get<any>({ url: `/admin/${uri}/getMenuIds`, params });
const initApi = (uri: string, params: any) =>
  apiClient.get<any>({ url: `/admin/${uri}/initUserPassword`, params });
const getCustomApi = (url: string, params: any) => apiClient.get<any>({ url, params });
const postCustomApi = (url: string, data: any) => apiClient.post<any>({ url, data });
const putCustomApi = (url: string, data: any) => apiClient.put<any>({ url, data });
const setStatusApi = (uri: string, params: any) =>
  apiClient.get<any>({ url: `/admin/${uri}/saleSet`, params });
const setEditApi = (uri: string, params: any) =>
  apiClient.get<any>({ url: `/admin/${uri}/editSet`, params });
const setTopApi = (uri: string, params: any) =>
  apiClient.get<any>({ url: `/admin/${uri}/topSet`, params });
const uploadApi = (data: any) =>
  apiClient.post<any>({
    url: `/common/upload`,
    data,
    headers: { 'Content-Type': 'multipart/form-data' },
  });
const getBaseApi = () => apiClient.get<any>({ url: `/common/baseProperty/getAllProperty` });

export default {
  getListApi,
  getApi,
  addApi,
  editApi,
  auditApi,
  delApi,
  getInfoApi,
  uploadApi,
  getCateListApi,
  getBaseApi,
  initApi,
  setPermApi,
  getMenuApi,
  getMenuIdsApi,
  setStatusApi,
  setTopApi,
  setEditApi,
  getCustomApi,
  postCustomApi,
  putCustomApi,
};
